﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web
{
    public partial class text : System.Web.UI.Page
    {
        MSL.Utility.Doc.Json json = new MSL.Utility.Doc.Json();
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dt = Helper.GetDt();

            string type = "H";
            switch (type)
            {
                case "A":
                    A(dt);
                    break;
                case "B":
                    break;
                case "C":
                    C();
                    break;
                case "E":
                    E();
                    break;
                case "F":
                    F(dt);
                    break;
                case "G":
                    G(11);
                    break;
                case "H":
                    H();
                    break;
                default:
                    break;
            }

        }

        public void G(int i)
        {
            lock (this)
            {
                if (i > 10)
                {
                    i--;
                    G(i);
                }
            }

        }

        public enum Color
        {
            RED, GREEN, BLANK, YELLOW
        }
        private void H()
        {
            //string text = "";
            //foreach (string item in Enum.GetNames(typeof(Color)))
            //{
            //    text += item + "\n";
            //}

            string providerName = "";

            string conn = String.Format(MSL.Utility.Config.Helper.GetProviderApp("Conn_Access", out providerName), @"F:\SqlServerData");
            int num = 0;
            //DataTable dt = MSL.DataBase.DbHelper.Query(conn, "select ID,Content,Title from Articles", false);
            //string conn1 = MSL.Utility.Config.Helper.GetProviderApp("Conn_Oracle1", out providerName);

            conn = MSL.Utility.Config.Helper.GetProviderApp("ConnectionString", out providerName);
            DataTable dt = MSL.DataBase.DbHelper.Query(conn, "SELECT TOP 10 id,name,summary,workOrgan,duty,photoPath FROM PeopleAll", false);
            dt = MSL.DataBase.DbHelper.Query(conn,
                "PeopleAll",
                "ID",
                "id,name,summary,workOrgan,duty,photoPath FROM PeopleAll",
                2,
                15,
                "deleteFlag is null",
                "peopleCode desc ",
                null,
                out num);
            //dt = MSL.DataBase.DbHelper.Query(conn1, "Artiles", "", "id,title,content", 5, 4, "1=1", " id desc", "", out num);


        }

        public static void SelectSort(IList<int> data)
        {
            int temp = 0;
            for (int i = 0; i < data.Count; i++)
            {
                int min = i;
                temp = data[i];
                for (int j = 1; j < data.Count; j++)
                {
                    temp = data[j];
                    if (data[j] < temp)
                        min = j;
                }
                if (i != min)
                {
                    data[min] = data[i];
                    data[i] = temp;
                }
            }
        }
        //DataTableToJson
        private void A(DataTable dt)
        {
            string temp = "";
            temp = json.DataToJson(dt, null);
        }
        //JsonToDataTable
        private void C()
        {
            DataTable dt = json.JsonToData(Helper.jsonText);
        }
        //JsonToObject 错误
        private void D()
        {
            DataTable dt = json.JsonToData(Helper.jsonText);
        }
        //JsonToDictionary
        private void E()
        {
            List<Dictionary<string, object>> list = json.JsonToDictionary(Helper.jsonText);
        }

        //DataTableToList
        private void F(DataTable dt)
        {
            //List<Dictionary<string, object>> list = json.DataToJson(dt);
        }
    }
}